package com.cn.system.service.impl;

import com.cn.system.contants.HttpResponseEnum;
import com.cn.system.entity.BaseResponse;
import com.cn.system.entity.TGroupCourse;
import com.cn.system.mapper.TGroupCourseMapper;
import com.cn.system.service.BaseService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("tGroupCourseServiceImpl")
public class TGroupCourseServiceImpl implements BaseService<TGroupCourse> {

  @Autowired
  private TGroupCourseMapper tGroupCourseMapper;

  @Override
  public TGroupCourse get(String id) {
    return null;
  }

  @Override
  public List<TGroupCourse> list(TGroupCourse tGroupCourse) {
    return tGroupCourseMapper.list(tGroupCourse);
  }

  @Override
  public BaseResponse<TGroupCourse> page(int startIndex, int endIndex, TGroupCourse tGroupCourse) {
    // 分页信息
    PageInfo<TGroupCourse> pageInfo = PageHelper.startPage(startIndex, endIndex)
            .doSelectPageInfo(() -> this.tGroupCourseMapper.page(tGroupCourse));
    // 构建输出
    BaseResponse baseResponse = new BaseResponse();
    baseResponse.setCode(HttpResponseEnum.HTTP_SUCCESS.getCode());
    baseResponse.setMessage(HttpResponseEnum.HTTP_SUCCESS.getMessage());
    baseResponse.setData(pageInfo);
    return baseResponse;
  }

  @Override
  public int update(TGroupCourse tGroupCourse) {
    return 0;
  }

  @Override
  public int delete(String id) {
    return 0;
  }

  @Override
  public int add(TGroupCourse tGroupCourse) {
    return tGroupCourseMapper.add(tGroupCourse);
  }
}
